<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工基金基数调整')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: bootstrap-editable-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<style>
    .fixed-table-container .bs-checkbox .th-inner {
        padding: 8px 8px !important;
    }
</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" name="allId" id="allId"/>
                <div class="select-list">
                    <ul>
                        <li>
                            <p>工号：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-plus"></i> 添加员工
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:welfareopen:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger" onclick="inspect('cSP_BeneChangeDec')"
               shiro:hasPermission="system:benefitbase:remove">
                <i class="fa fa-remove"></i> 删除员工
            </a>

            <a class="btn btn-primary" onclick="inspect('cSP_BeneChangeAccuCheck')"
               shiro:hasPermission="system:welfareopen:edit">
                <i class="fa fa-edit"></i> 确认检查
            </a>
            <a class="btn btn-danger" onclick="inspect('cSP_BeneChangeAccuCancel')"
               shiro:hasPermission="system:benefitbase:remove">
                <i class="fa fa-remove"></i> 取消确认
            </a>

            <a class="btn btn-warning" onclick="inspect('cSP_BeneChangeAccuStart')"
               shiro:hasPermission="system:benefitbase:export">
                <i class="fa fa-download"></i> 处理生效
            </a>

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + 'welfare/welfarebaseadjustment/accubaseadjustment';

    function inspect(storage) {
        var allId = "";
        var procedure = storage;
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        if (row.length == 0) {
            $.modal.alertWarning("请选择数据!");
            return;
        } else {
            $.ajax({
                async: false,
                url: prefix + "/procedure",
                data: {
                    allId: allId,
                    procedure: procedure

                },
                type: "post",
                dataType: "json",
                success: function (data) {

                    if (procedure == "cSP_BeneChangeAccuCheck" && data.code == 0) {
                        $("#allId").val(allId);
                        $.modal.alertWarning("操作成功!");
                        $("#bootstrap-table").bootstrapTable("refresh");
                    } else if (data.code == 500) {
                        $.modal.alertWarning("服务器繁忙!");
                        $("#bootstrap-table").bootstrapTable("refresh");
                    } else if (data.code == 0) {
                        $.modal.alertWarning("操作成功!");
                        $("#allId").val('');
                        $("#bootstrap-table").bootstrapTable("refresh");
                    } else {
                        $.modal.alertWarning(data.message);
                        $("#bootstrap-table").bootstrapTable("refresh");
                    }
                },

            });
        }
    }

    $(function () {
        var options = {
            code: 'id',
            uniqueId: 'id',
            url: prefix + '/list',
            createUrl: prefix + '/add',
            updateUrl: prefix + '/edit/{id}',
            height: $(window).height() - 120,
            modalName: "公积金基数调整",
            columns: [
                [
                    {
                        checkbox: true,
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'id',
                        title: '序号',
                        rowspan: 2,
                        valign:"middle"

                    },
                    {
                        field: 'badge',
                        title: '工号',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'name',
                        title: '姓名',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'compName',
                        title: '公司名称',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'depName',
                        title: '部门名称',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'jobName',
                        title: '工作岗位',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'benefitStatus',
                        title: '福利缴纳状态',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'benefitCity',
                        title: '社保缴纳地区',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'accuCity',
                        title: '公积金缴纳地区',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'effectdate',
                        title: '生效日期',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'remark',
                        title: '备注',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'regbyName',
                        title: '登记人',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'regTime',
                        title: '登记时间',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'initialized',
                        title: '？确认',
                        formatter: function (value, row, index) {
                            if (row.initialized == 1) {
                                return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                            } else {
                                return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                            }
                        },
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'initializedbyName',
                        title: '确认人',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        field: 'initializedtime',
                        title: '确认时间',
                        rowspan: 2,
                        valign:"middle"
                    },
                    {
                        title: '公积金基数',
                        rowspan: 1,
                        colspan: 2,
                        align:"center"
                    },
                ],
                [
                    {
                        field: 'oldXvalue',
                        title: '原基数',
                        rowspan: 1
                    },
                    {
                        field: 'Xvalue',
                        title: '新基数',
                        rowspan: 1
                    }
                ],
            ]
        }
        $.table.init(options);
    })
</script>
</body>
</html>